home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
PIL
/
XbmImagePlugin.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
2KB
|
55 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
__version__ = '0.6'
import re
import string
import Image
import ImageFile
xbm_head = re.compile('\\s*#define[ \t]+[^_]*_width[ \t]+(?P<width>[0-9]+)[\r\n]+#define[ \t]+[^_]*_height[ \t]+(?P<height>[0-9]+)[\r\n]+(?P<hotspot>#define[ \t]+[^_]*_x_hot[ \t]+(?P<xhot>[0-9]+)[\r\n]+#define[ \t]+[^_]*_y_hot[ \t]+(?P<yhot>[0-9]+)[\r\n]+)?[\\000-\\377]*_bits\\[\\]')
def _accept(prefix):
return string.lstrip(prefix)[:7] == '#define'
class XbmImageFile(ImageFile.ImageFile):
format = 'XBM'
format_description = 'X11 Bitmap'
def _open(self):
m = xbm_head.match(self.fp.read(512))
if m:
xsize = int(m.group('width'))
ysize = int(m.group('height'))
if m.group('hotspot'):
self.info['hotspot'] = (int(m.group('xhot')), int(m.group('yhot')))
self.mode = '1'
self.size = (xsize, ysize)
self.tile = [
('xbm', (0, 0) + self.size, m.end(), None)]
def _save(im, fp, filename):
if im.mode != '1':
raise IOError, 'cannot write mode %s as XBM' % im.mode
fp.write('#define im_width %d\n' % im.size[0])
fp.write('#define im_height %d\n' % im.size[1])
hotspot = im.encoderinfo.get('hotspot')
if hotspot:
fp.write('#define im_x_hot %d\n' % hotspot[0])
fp.write('#define im_y_hot %d\n' % hotspot[1])
fp.write('static char im_bits[] = {\n')
ImageFile._save(im, fp, [
('xbm', (0, 0) + im.size, 0, None)])
fp.write('};\n')
Image.register_open('XBM', XbmImageFile, _accept)
Image.register_save('XBM', _save)
Image.register_extension('XBM', '.xbm')
Image.register_mime('XBM', 'image/xbm')